home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Compilers / digital marsC compier / dm / include / Stdio.asm < prev    next >
Encoding:
Assembly Source File  |  1997-01-02  |  6.4 KB  |  369 lines

  1. ;_ stdio.asm   
  2. ; Copyright (C) 1985-1990 by Walter Bright    */
  3. ; All rights reserved.                */
  4. ; $Revision: 1.1.1.1 $ 
  5. ; Standard I/O header file    */
  6.  
  7. EOF    equ    -1
  8.  
  9. ifdef _WIN32
  10. ifndef __NT__
  11. __NT__ equ 1
  12. endif
  13. endif
  14.  
  15. ifdef __NT__
  16. _NFILE    equ    60
  17. else
  18. ifdef M_UNIX
  19. _NFILE    equ    60
  20. else
  21. ifdef M_XENIX
  22. _NFILE    equ    60
  23. else
  24. _NFILE    equ    40
  25. endif
  26. endif
  27. endif
  28.  
  29. ifdef    M_I386
  30.  
  31. BUFSIZ        equ    4096
  32.  
  33. ifdef DOS386
  34. _ptr    equ    0
  35. _cnt    equ    _ptr + SIZEPTR
  36. _base    equ    _cnt + 4
  37. _flag    equ    _base + SIZEPTR
  38. _file    equ    _flag + 4
  39. _bufsiz equ    _file + 4
  40. else
  41. ifdef __OS2__
  42. _ptr        equ    0
  43. _cnt        equ    4
  44. _base        equ    8
  45. _flag        equ    12
  46. _file        equ    16
  47. _charbuf    equ    20
  48. _bufsiz        equ    24
  49. __tmpnum    equ    28
  50. else
  51. ifdef __NT__
  52. _ptr        equ    0
  53. _cnt        equ    4
  54. _base        equ    8
  55. _flag        equ    12
  56. _file        equ    16
  57. _bufsiz        equ    20
  58. __tmpnum    equ    24
  59. else    ; M_UNIX and M_XENIX
  60. _cnt    equ    0
  61. _ptr    equ    _cnt + 4
  62. _base    equ    _ptr + SIZEPTR
  63. _flag    equ    _base + SIZEPTR
  64. _file    equ    _flag + 1
  65. endif
  66. endif
  67. endif
  68.  
  69. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  70. ;Thread data structure (one is allocated per thread)
  71. ;Must match __thread1 in cinit.asm and struct THREAD in mt.h
  72.  
  73.     ifdef __NT__
  74. thread_t struc
  75.     t_stackoff    dd    0
  76. ;    t_stackseg    dw    0
  77.     t_parameter    dd    0
  78.     t_func        dd    0
  79.     t_stacktop    dd    0
  80.     t_errno        dd    0
  81. ;   if SPTR
  82.     t_strtok    dd    0
  83. ;   else
  84. ;    t_strtok    df    0
  85. ;   endif
  86. ;   ifdef __NT__
  87.     t_id        dd    0    ;thread id
  88.     t_hndl        dd    0    ;thread handle
  89.     t_envptr    dd    0    ;pointer to malloced memory for getenv return
  90. ;   endif
  91.     t_tm        dd    9 dup (0)    ;struct tm
  92.  
  93.     ;Actually t_fenv
  94.     t_fe_status    dw    0
  95.     t_fe_control    dw    0
  96.     t_fe_round    dw    0
  97.     t_fe_res1    dw    0
  98.     t_fe_res2    dw    0
  99.  
  100.     t_asctime    db    26 dup (0)
  101.     t_digstr    db    32 dup (0)    ;DBL_DIG*2+2
  102.     t_doserrno      dd      0
  103.  
  104. ; see to MT.H, STDIO.ASM(This file), CINIT.ASM.
  105.     t_wcstok    dd    0        ;wcstok()
  106.     t_wenvptr    dd    0        ;wgetenv()
  107.     t_wasctime    dw    26 dup (0)    ;wasctime()
  108.     t_cppeh_sv  dd      114 dup (0)       ;global statics for cplusplus exceptions..
  109.  
  110. thread_t ends
  111.     else
  112. thread_t struc
  113.     t_stackoff    dd    0
  114. ;    t_stackseg    dw    0
  115.     t_parameter    dd    0
  116.     t_func        dd    0
  117.     t_stacktop    dd    0
  118.     t_errno        dd    0
  119. ;   if SPTR
  120.     t_strtok    dd    0
  121. ;   else
  122. ;    t_strtok    df    0
  123. ;   endif
  124. ;   ifdef __NT__
  125. ;    t_id        dd    0    ;thread id
  126. ;    t_hndl        dd    0    ;thread handle
  127. ;    t_envptr    dd    0    ;pointer to malloced memory for getenv return
  128. ;   endif
  129.     t_tm        dd    9 dup (0)    ;struct tm
  130.  
  131.     ;Actually t_fenv
  132.     t_fe_status    dw    0
  133.     t_fe_control    dw    0
  134.     t_fe_round    dw    0
  135.     t_fe_res1    dw    0
  136.     t_fe_res2    dw    0
  137.  
  138.     t_asctime    db    26 dup (0)
  139.     t_digstr    db    32 dup (0)    ;DBL_DIG*2+2
  140.     t_doserrno      dd      0
  141.     
  142.     ifdef DOS386
  143.     t_cppeh_sv      dd      110 dup (0) 
  144.     else
  145.     
  146.     if LCODE
  147.     ;; Large or Medium
  148.     if LPTR
  149.     t_cppeh_sv    db      350 dup (0)     ; globals for CPP exception handling.
  150.     else
  151.     t_cppeh_sv     db      268 dup (0)
  152.     endif
  153.  
  154.     else
  155.     ;; Compact or Small
  156.     if LPTR
  157.     t_cppeh_sv     db      330 dup (0)
  158.     else
  159.     t_cppeh_sv     db      248 dup (0)
  160.     endif
  161.     endif ;; LCODE
  162.     
  163.     endif ;; DOS386
  164.  
  165. thread_t ends
  166.     endif
  167.  
  168. THDSIZE    equ    (size thread_t)
  169.  
  170. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  171.  
  172. ifdef _MT
  173.  
  174.   ifndef noerrno
  175.     if LCODE
  176.     extrn    __errno_set:far
  177.     else
  178.     extrn    __errno_set:near
  179.     endif
  180.   endif
  181.  
  182. errno_set macro    value
  183.     ifnb <value>
  184.     mov    EAX,value
  185.     endif
  186.     call    __errno_set
  187.     endm
  188.  
  189. else
  190.  
  191.  ifndef noerrno
  192.     begdata
  193.     extrn    _errno:dword
  194.     enddata
  195.  endif
  196.  
  197. errno_set macro    value
  198.     ifnb <value>
  199.     mov    _errno,value
  200.     else
  201.     mov    _errno,EAX
  202.     endif
  203.     endm
  204.  
  205. endif
  206.  
  207. else    ;M_I386
  208.  
  209. BUFSIZ        equ    1024
  210.     IF SPTR
  211. BIGBUF        equ    20 * 1024
  212.     ENDIF
  213.  
  214. _ptr    equ    0
  215. _cnt    equ    _ptr + SIZEPTR
  216. _base    equ    _cnt + 2
  217. _flag    equ    _base + SIZEPTR
  218. _file    equ    _flag + 2
  219. _bufsiz equ    _file + 2
  220.     IFDEF    BIGBUF
  221. _seg    equ    _bufsiz + 2
  222.     ENDIF
  223.  
  224. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  225. ;Thread data structure (one is allocated per thread)
  226. ;Must match __thread1 in cinit.asm and struct THREAD in mt.h
  227.  
  228. thread_t struc
  229.     t_stackoff    dw    0
  230.     t_stackseg    dw    0
  231.     t_stacktop    dw    0
  232.     t_errno        dw    0
  233.     t_strtok    dd    0
  234.     t_tm        dw    9 dup (0)    ;struct tm
  235.  
  236.     ;Actually fenv_t
  237.     t_fe_status    dw    0
  238.     t_fe_control    dw    0
  239.     t_fe_round    dw    0
  240.     t_fe_res1    dw    0
  241.     t_fe_res2    dw    0
  242.  
  243.     t_asctime    db    26 dup (0)
  244.     t_digstr    db    32 dup (0)    ;DBL_DIG*2+2
  245.     t_doserrno      dw      0
  246. thread_t ends
  247.  
  248. THDSIZE    equ    (size thread_t)
  249.  
  250. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  251.  
  252. ifdef _MT
  253.  
  254.   ifndef noerrno
  255.     if LCODE
  256.     extrn    __errno_set:far
  257.     else
  258.     extrn    __errno_set:near
  259.     endif
  260.   endif
  261.  
  262. errno_set macro    value
  263.     ifnb <value>
  264.     mov    AX,value
  265.     endif
  266.     call    __errno_set
  267.     endm
  268.  
  269. else
  270.  
  271.  ifndef noerrno
  272.     begdata
  273.     extrn    _errno:word
  274.     enddata
  275.  endif
  276.  
  277. errno_set macro    value
  278.     ifnb <value>
  279.     mov    _errno,value
  280.     else
  281.     mov    _errno,AX
  282.     endif
  283.     endm
  284.  
  285. endif
  286.  
  287. endif
  288.  
  289. _IOREAD        equ    1
  290. _IOWRT        equ    2
  291. _IONBF        equ    4
  292. _IOMYBUF    equ    8
  293. _IOEOF        equ    10h
  294. _IOERR        equ    20h
  295. _IOLBF        equ    40h
  296. _IORW        equ    80h
  297. _IOTRAN        equ    100h
  298. _IOAPP        equ    200h
  299.     ifdef    BIGBUF
  300. _IOBIGBUF    equ    400h
  301.     endif
  302.  
  303.  
  304. ;Values for errno
  305. ifdef M_UNIX 
  306. ENOENT        equ    2
  307. EACCES        equ    13
  308. EINVAL        equ    22
  309. ENOMEM        equ    12
  310. EDEADLOCK    equ    56
  311. EEXIST        equ    17
  312. ERANGE        equ    34
  313. else
  314. ifdef M_XENIX
  315. ENOENT        equ    2
  316. EACCES        equ    13
  317. EINVAL        equ    22
  318. ENOMEM        equ    12
  319. EDEADLOCK    equ    56
  320. EEXIST        equ    17
  321. ERANGE        equ    34
  322. else
  323. EZERO           equ     0
  324. EPERM           equ     1
  325. ENOENT          equ     2
  326. ESRCH           equ     3
  327. EINTR           equ     4
  328. EIO             equ     5
  329. ENXIO           equ     6
  330. E2BIG           equ     7
  331. ENOEXEC         equ     8
  332. EBADF           equ     9
  333. ECHILD          equ     10
  334. EAGAIN          equ     11
  335. ENOMEM          equ     12
  336. EACCES          equ     13
  337. EFAULT          equ     14
  338. ENOTBLK         equ     15
  339. EBUSY           equ     16
  340. EEXIST          equ     17
  341. EXDEV           equ     18
  342. ENODEV          equ     19
  343. ENOTDIR         equ     20
  344. EISDIR          equ     21
  345. EINVAL          equ     22
  346. ENFILE          equ     23
  347. EMFILE          equ     24
  348. ENOTTY          equ     25
  349. ETXTBSY         equ     26
  350. EFBIG           equ     27
  351. ENOSPC          equ     28
  352. ESPIPE          equ     29
  353. EROFS           equ     30
  354. EMLINK          equ     31
  355. EPIPE           equ     32
  356. EDOM            equ     33
  357. ERANGE          equ     34
  358. EUCLEAN         equ     25
  359. EDEADLOCK       equ     36
  360. EDEADLK         equ     36
  361. ENAMETOOLONG    equ     38
  362. ENOLCK          equ     39
  363. ENOSYS          equ     40
  364. ENOTEMPTY       equ     41
  365. EILSEQ          equ     42
  366. endif
  367. endif
  368.  
  369.